package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;

/**
 * Controller class for the address book
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class AddressCtr
{
    

    private AddressBook addressBook;

    
    //Address container is to be passed as parameter from the main controller
    public AddressCtr()
    {
        addressBook = AddressBook.getInstance();
    }
    
    //Dummy implementation: after implementing the model layer 
    //objects of class Person are to be returned, not String
    public Person getPerson(long id)
    {
        Person p = addressBook.getPerson(id);
        return p;
    }
    
    public void createPerson(long id, String name, String address, int zipCode, String city, int phone)

    {   
        Person p = new Person(id, name, address, zipCode, city, phone);
        addressBook.addPerson(p);
    }
    
    public void deletePerson(long id)
    {
       addressBook.deletePerson(id);
    }
    
    public void updatePerson(long id, String name, String address, int zipCode, String city, int phone)
    {

       addressBook.updatePerson(id, name, address, zipCode, city, phone);

    }
    
    public ArrayList listAllPersons()
    {
        ArrayList<Person> persons = new ArrayList<Person>();
        persons = addressBook.listAllPersons();
        
          return persons;
    }
}